﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using U9API.Pub;

namespace U9API.Controllers
{
    public class ICustomerSVController : BaseController
    {
        // GET: MaterialOut
        public ActionResult Index()
        {
            return View();
        }
        [System.Web.Mvc.HttpPost]
        public String Create()
        {
            JsonModel.APIResponse result = new JsonModel.APIResponse();
            String data = String.Empty;
            try
            {
                APIRequest request = new APIRequest(this.HttpContext);
                data = request.data;
                JsonModel.ApiCustomer model = JsonConvert.DeserializeObject<U9API.JsonModel.ApiCustomer>(request.data);

                Pub.WriteLog.WriteLine("reqtime=" + DateTime.Now);
                U9API.APIHelper.ICustomerSVHelper helper = new APIHelper.ICustomerSVHelper();
                
                helper.Create(helper.U9Constr, request.operation, model);


                result.SetSuccessed(helper.custRes.ToJson());
                
                result.message = helper.outmessage;
            }
            catch (Exception ex)
            {
                Pub.WriteLog.WriteLine("CustomerController", "Create", ex);
                Pub.WriteLog.WriteLine(data);
                result.SetError(ex.Message);
            }
            return result.ToJson();
        }
    }
}